﻿using System;
using OS.Infrastructure.Domain;

namespace TaskKernel.Domain
{
    public class File : AbstractEntity
    {
        protected File()
        {
        }

        public File(String filename, byte[] content, int hash)
            : this()
        {
            FileName = filename;
            DateCreate = DateTime.Now;
            Hash = hash;
            if (content == null) return;
            Content = content;
            Size = content.Length;
        }

        public virtual string FileName { get; protected set; }
        public virtual int Size { get; protected set; }
        public virtual Account Owner { get; protected set; }
        public virtual int Hash { get; protected set; }
        public virtual DateTime DateCreate { get; protected set; }
        public virtual byte[] Content { get; protected set; }
        public virtual Task Task { get; protected set; }

        public virtual void SetContent(byte[] content)
        {
            Content = content;
        }
        public virtual void SetHash(int hash)
        {
            Hash = hash;
        }

        public virtual void SetOwner(Account account)
        {
            Owner = account;
        }

        public virtual void SetTask(Task task)
        {
            Task = task;
        }
    }
}